﻿@page
@model IndexModel
@{
    ViewData["Title"] = "Home page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>


<div class="text-center">
    <ul id="contacts"></ul>
</div>

@section Scripts {
    <script>
        $(function () {
        var url = "https://www.one.com:8080/api/Contact";
            $.getJSON(url, null, function (contacts) {
                $.each(contacts, function (index, contact) {
                    var html = '<li><ul>';
                    html += '<li>Name: ' + contact.Name + '</li>';
                    html += '<li>Phone No:' + contact.PhoneNo + '</li>';
                    html += '<li>Email Address: ' + contact.EmailAddress + '</li>';
                    html += '</ul>';
                    $('#contacts').append($(html));
                });
            });
        });
    </script>
}